package com.dhsc.service.impl.wdywgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhsc.domain.ywzx.wdywgl.CywjjxsgfVo;
import com.dhsc.domain.ywzx.wdywgl.CyyjjxsggrVo;
import com.dhsc.domain.ywzx.wdywgl.HsscdxfsjVo;
import com.dhsc.domain.yypt.LayuiTableVo;
import com.dhsc.exception.MyException;
import com.dhsc.local.dao.wdywgl.IXsjdxfsjDao;
import com.dhsc.service.wdywgl.IXsjdxfsjService;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;

import lombok.extern.slf4j.Slf4j;

/**
 * @ClassName: XsjdxfsjServiceImpl
 * @Description: 限售及大小非数据
 * @date: 2023/1/16 14:07
 * @author: jwj
 */
@Service
@Slf4j
public class XsjdxfsjServiceImpl implements IXsjdxfsjService {

    @Autowired
    private IXsjdxfsjDao xsjdxfsjDao;

    @Override
    public LayuiTableVo queryCywjjxsgf(CywjjxsgfVo cywjjxsgfVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            PageMethod.startPage(cywjjxsgfVo.getPage(),cywjjxsgfVo.getLimit());
            List<CywjjxsgfVo> list = xsjdxfsjDao.queryCywjjxsgf(cywjjxsgfVo);
            PageInfo<CywjjxsgfVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
            obj.setMsg("");
        }catch (Exception e){
            log.error("查询持有未解禁限售股份信息异常",e);
            throw new MyException("查询持有未解禁限售股份信息异常",e);
        }
        return obj;
    }

    @Override
    public LayuiTableVo queryCyyjjxsggr(CyyjjxsggrVo cyyjjxsggrVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            PageMethod.startPage(cyyjjxsggrVo.getPage(),cyyjjxsggrVo.getLimit());
            List<CyyjjxsggrVo> list = xsjdxfsjDao.queryCyyjjxsggr(cyyjjxsggrVo);
            PageInfo<CyyjjxsggrVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
            obj.setMsg("");
        }catch (Exception e){
            log.error("查询持有已解禁限售股个人信息异常",e);
            throw new MyException("查询持有已解禁限售股个人信息异常",e);
        }
        return obj;
    }

    @Override
    public LayuiTableVo queryHsscdxfsjcx(HsscdxfsjVo hsscdxfsjVo) {
        LayuiTableVo obj = new LayuiTableVo();
        try {
            //如果是导出，则查所有记录
            if(hsscdxfsjVo.getExportFlag()!=1){
                PageMethod.startPage(hsscdxfsjVo.getPage(),hsscdxfsjVo.getLimit());
            }
            List<HsscdxfsjVo> list = xsjdxfsjDao.queryHsscdxfsjcx(hsscdxfsjVo);
            PageInfo<HsscdxfsjVo> pageInfo = new PageInfo<>(list);
            obj.setData(list);
            obj.setCount(pageInfo.getTotal());
            obj.setCode(0);
            obj.setMsg("");
        }catch (Exception e){
            log.error("沪深市场大小非数据查询信息异常",e);
            throw new MyException("沪深市场大小非数据查询信息异常",e);
        }
        return obj;
    }

}
